import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/utils/log.dart';

class RegisterLicence extends StatefulWidget {
  @override
  State<RegisterLicence> createState() => _RegisterLicenceState();
}

class _RegisterLicenceState extends State<RegisterLicence> {
  final box = Hive.box('appconfig');

  @override
  Widget build(BuildContext context) {
    Log.debug('build product licence');

    return GridView.builder(
      itemCount: Constants.productLicences.length,
      gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
          maxCrossAxisExtent: 500,
          childAspectRatio: 156 / 200,
          crossAxisSpacing: 12,
          mainAxisSpacing: 12),
      itemBuilder: (context, index) {
        return Flex(
          direction: Axis.vertical,
          children: <Widget>[
            Container(
              height: 300,
              child: Card(
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 20),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      const SizedBox(height: 25),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          Text('${Constants.productLicences[index].title}'.tr,
                              style: TextStyle(
                                  color: Color.fromARGB(255, 105, 158, 200),
                                  fontSize: 20,
                                  fontWeight: FontWeight.w500)),
                        ],
                      ),

                      const SizedBox(height: 20),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          Expanded(
                              child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                Text('${Constants.productLicences[index].text}'
                                    .tr),
                              ])),
                        ],
                      ),
                      //Divider(color: Colors.black),
                      // for not purchased
                      const SizedBox(height: 30),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          Text('noActive'.tr),
                        ],
                      ),
                      const SizedBox(height: 20),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: <Widget>[
                          OutlinedButton(
                            child: Text(
                                '${Constants.productLicences[index].button}'
                                    .tr),
                            onPressed: () {
                              Get.toNamed('/register/userinfo',
                                  arguments:
                                      '${Constants.productLicences[index].lable}');
                            },
                          ),
                          const SizedBox(width: 8),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        );
      },
    );
  }
}
